package com.liu.yubi.easyexcel;

import cn.hutool.core.text.StrBuilder;
import cn.hutool.json.JSONUtil;
import com.liu.yubi.config.JsonConfig;
import com.liu.yubi.manager.DBAiManager;
import com.liu.yubi.manager.ZPAIManager;
import com.liu.yubi.utils.AiUtils;
import com.zhipu.oapi.service.v4.model.ChatMessage;
import com.zhipu.oapi.service.v4.model.ChatMessageRole;
import com.zhipu.oapi.service.v4.model.ZhiPuAiError;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* @author lqh
* @since 2025-05-27 21:55
 *
*/
@SpringBootTest
public class Demo1 {

    @Resource
    private ZPAIManager zpaiManager;
    @Autowired
    private DBAiManager dBAiManager;
    @Autowired
    private JsonConfig jsonConfig;

    @Test
    void test01() {
        StrBuilder input = new StrBuilder ();
        input.append ("分析需求：\n" +
                "分析网站用户的增长趋势\n" +
                "原始数据：\n" +
                "日期，人数\n" +
                "1号，10\n" +
                "2号，8\n" +
                "3号，15\n");
        String res = zpaiManager.doChat (new ChatMessage (ChatMessageRole.USER.value (), input.toString ()));
        System.out.println (res);
    }

    @Test
    void test02(){
        String res = "{\n" +
                "    xAxis: {\n" +
                "        type: 'category',\n" +
                "        data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14']\n" +
                "    },\n" +
                "    yAxis: {\n" +
                "        type: 'value'\n" +
                "    },\n" +
                "    series: [\n" +
                "        {\n" +
                "            data: [10, 20, 30, 13, 12, 21, 15, 16, 34, 45, 24, 34, 45, 56],\n" +
                "            type: 'bar',\n" +
                "            stack: 'total'\n" +
                "        }\n" +
                "    ]\n" +
                "}";
        System.out.println (AiUtils.genCodeToJson (res));
    }
}
